﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

namespace scmsByAspdNet.cotro.admin {
  /// <summary>
  /// deleteCourse 的摘要说明
  /// </summary>
  public class deleteCourse : IHttpHandler {
    public void ProcessRequest(HttpContext context) {
      string id = context.Request["id"].ToString();
      //数据库
      SqlConnection conn = new SqlConnection("Data Source=106.54.69.143;database=scms;uid=sa;pwd=Aspdotnet666");
      conn.Open();
      //声明返回的数据
      string ret = "";
      //创建SQL命令
      string sql = $"update sc_course set is_deleted = 1 where id = {id}";
      SqlCommand cmd = new SqlCommand(sql, conn);
      //执行SQL命令
      int res = cmd.ExecuteNonQuery();
      //获取SqlDataReader
      conn.Close();
      //返回数据
      context.Response.StatusCode = 200;
      context.Response.Write($"{{\"code\":0,\"lines\":{res}}}");
    }

    public bool IsReusable {
      get {
        return false;
      }
    }
  }
}